package com.ctshk.app.system.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.system.dto.mian.data.MainDataNotGroupRulesDTO;
import com.ctshk.rpc.system.dto.mian.data.MainDataTourTemplateDTO;
import com.ctshk.rpc.system.req.main.data.*;
import com.ctshk.rpc.system.service.IMainDataTourTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 系列团模板表 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-28
 */
@Api(value = "主数据模板表", tags = "主数据模板管理")
@RestController
@RequestMapping("/main/data/tour/template")
public class MainDataTourTemplateController extends BaseController {

    @DubboReference
    private IMainDataTourTemplateService mainDataTourTemplateService;

    @ApiOperation(value = "新增系列团模板", notes = "新增系列团模板")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增系列团模板", operDesc = "新增系列团模板")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataTourTemplateReq mainDataNotGroupRulesReq) {
        mainDataTourTemplateService.add(mainDataNotGroupRulesReq, getCurrentUser(getRequest()));
        return Result.success();
    }

    @ApiOperation(value = "编辑系列团模板", notes = "编辑系列团模板")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑系列团模板", operDesc = "编辑系列团模板")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataTourTemplateReq mainDataTourTemplateReq) {
        mainDataTourTemplateService.update(mainDataTourTemplateReq, getCurrentUser(getRequest()));
        return Result.success();
    }


    @ApiOperation(value = "删除系列团模板", notes = "删除系列团模板")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.DELETE, operTitle = "删除系列团模板", operDesc = "删除系列团模板")
    @PostMapping("/delete")
    public Result delete(@RequestBody @Valid MainDataTourTemplateIdReq mainDataTourTemplateIdReq) {
        mainDataTourTemplateService.delete(mainDataTourTemplateIdReq, getCurrentUser(getRequest()));
        return Result.success();
    }


    @ApiOperation(value = "查询系列团模板列表", notes = "查询系列团模板列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询系列团模板列表", operDesc = "查询系列团模板列表")
    @PostMapping("/queryList")
    public Result<PageResponse<MainDataTourTemplateDTO>> queryList(@RequestBody @Valid MainDataTourTemplateQueryReq mainDataTourTemplateQueryReq) {
        return Result.success(mainDataTourTemplateService.queryList(mainDataTourTemplateQueryReq, getCurrentUser(getRequest())));
    }


    @ApiOperation(value="设置状态接口（有效，无效）", notes="设置状态接口（有效，无效）")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "设置状态接口（有效，无效）", operDesc = "设置状态接口（有效，无效）")
    @PostMapping("/update/status")
    public Result updateStatus(@RequestBody @Valid MainDataTourTemplateIdReq mainDataTourTemplateIdReq) {
        mainDataTourTemplateService.updateStatus(mainDataTourTemplateIdReq,getCurrentUser(getRequest()));
        return Result.success();
    }

    @ApiOperation(value = "查询系列团模板id", notes = "查询系列团模板id")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查询系列团模板id", operDesc = "查询系列团模板id")
    @PostMapping("/queryTemplateId")
    public Result<MainDataTourTemplateDTO> queryTemplateId(@RequestBody @Valid MainDataTourTemplateIdReq mainDataTourTemplateIdReq) {
        return Result.success(mainDataTourTemplateService.queryTemplateId(mainDataTourTemplateIdReq, getCurrentUser(getRequest())));
    }

}
